package com.zxw.service.impl;

import com.aaa.entity.GSort;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zxw.dao.GSortMapper;
import com.zxw.service.GSortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86176
* @description 针对表【g_sort(商品类别)】的数据库操作Service实现
* @createDate 2023-02-28 17:23:24
*/
@Service
@SuppressWarnings("all")
public class GSortServiceImpl extends ServiceImpl<GSortMapper, GSort>
    implements GSortService{
    @Autowired
    private GSortMapper gSortMapper;

    @Override
    public Result findAllSorts(GSort gsort, Integer pageCurrent, Integer pageSize) {
        PageHelper.startPage(pageCurrent, pageSize);
        List<GSort> allSort = gSortMapper.findAllSorts(gsort.getId(), gsort.getStatus());
        PageInfo<GSort> pageInfo = new PageInfo<>(allSort);
        return new Result<>(2000,"查询成功",pageInfo);
    }

    @Override
    public Result findAllSort() {
        QueryWrapper queryWrapper = new QueryWrapper();
        List<GSort> list = gSortMapper.selectList(queryWrapper);
        return new Result<>(2000,"查询成功",list);
    }

    @Override
    public Result updateSort(GSort gsort) {
        gSortMapper.updateById(gsort);
        return new Result<>(2000,"修改成功");
    }

    @Override
    public Result deleteSort(Integer id) {
        gSortMapper.deleteById(id);
        return new Result<>(2000,"删除成功");
    }


}




